

package com.hazelcast.jet.impl.connector;

import com.hazelcast.function.SupplierEx;
import com.hazelcast.jet.test.IgnoreInJenkinsOnWindows;
import com.hazelcast.test.annotation.NightlyTest;
import com.hazelcast.test.annotation.ParallelJVMTest;
import com.rabbitmq.jms.admin.RMQConnectionFactory;
import jakarta.jms.ConnectionFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.experimental.categories.Category;
import org.testcontainers.containers.RabbitMQContainer;

import static com.hazelcast.test.DockerTestUtil.assumeDockerEnabled;

@Category({NightlyTest.class, ParallelJVMTest.class, IgnoreInJenkinsOnWindows.class})
public class JmsSourceIntegrationTest_RabbitMQ extends JmsSourceIntegrationTestBase {

    public static RabbitMQContainer container = new RabbitMQContainer("rabbitmq:3.8");

    private static final SupplierEx<ConnectionFactory> FACTORY_SUPPLIER = () -> {
        RMQConnectionFactory f = new RMQConnectionFactory();
        f.setUri(container.getAmqpUrl());
        return f;
    };

    @BeforeClass
    public static void beforeClassCheckDocker() {
        assumeDockerEnabled();
        container.start();
    }

    @AfterClass
    public static void afterAll() {
        if (container != null) {
            container.stop();
        }
    }

    @Override
    protected SupplierEx<ConnectionFactory> getConnectionFactory() {
        return FACTORY_SUPPLIER;
    }

    @Override
    public void stressTest_exactlyOnce_forceful_durableTopic() {
        // ignore this test for RabbitMQ, it doesn't support JMS 2.0
    }
}
